package cc.lj.internal.merchant;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.concurrent.TimeUnit;

@SpringBootApplication
@EnableSwagger2
@MapperScan("cc.lj.internal.merchant.infrastructure.dao")
public class MerchantApp {
    public static void main(String[] args)
    {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(MerchantApp.class, args);
        /**
         * 读取注册中心的配置demo
         **/
        /**
        while (true) {
            // 当动态配置刷新时，会更新到 Enviroment 中，因此这里每隔一秒中从 Enviroment 中获取配置
            String userName = applicationContext.getEnvironment().getProperty("base.name");
            String userAge = applicationContext.getEnvironment().getProperty("base.age");
            System.err.println("name :" + userName + "; age: " + userAge);
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }**/
    }
}
